package com.bangf.helper;

import com.bangf.domain.*;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Random;

/**
 * @deprecation: 创建实例助手
 * @email: leichuqiao@126.com
 * @author: 雷楚桥
 * @date: 2018/7/23 17:18
 */
@Component
public class EntityHelper {

    @PostConstruct
    public void init() {
    }


    /**
     * @param townId      Integer 乡镇id
     * @param fellGood    Double 感觉满意
     * @param fellGeneral Double 感觉一般
     * @param fellBad     Double 感觉不好
     * @return FpSatisfy
     * @deprecation 创建一个乡镇满意度实例
     * @author 雷楚桥
     * @date 2018-09-09 10:19
     */
    public FpSatisfy createSatisfy(Integer townId,
                                   Double fellGood,
                                   Double fellGeneral,
                                   Double fellBad) {
        FpSatisfy satisfy = new FpSatisfy();
        satisfy.setTownId(townId);
        satisfy.setFellGood(fellGood);
        satisfy.setFellGeneral(fellGeneral);
        satisfy.setFellBad(fellBad);

        return satisfy;
    }

    /**
     * @param townId      Integer 乡镇id
     * @param fellGood    Double 感觉满意
     * @param fellGeneral Double 感觉一般
     * @param fellBad     Double 感觉不好
     * @return FpEvaluation
     * @deprecation 创建一个乡镇评价表实例
     * @author 雷楚桥
     * @date 2018-09-09 10:19
     */
    public FpEvaluation createEvaluation(Integer townId,
                                         Double fellGood,
                                         Double fellGeneral,
                                         Double fellBad) {
        FpEvaluation evaluation = new FpEvaluation();
        evaluation.setTownId(townId);
        evaluation.setFellGood(fellGood);
        evaluation.setFellGeneral(fellGeneral);
        evaluation.setFellBad(fellBad);

        return evaluation;
    }

    /**
     * @param householdSum     Integer 总户数
     * @param poorHouseholdSum Integer 贫困户数
     * @param poorSum          Integer 贫困人数
     * @param helperSum        Integer 帮扶人数
     * @return
     * @deprecation 创建一个总统计实例
     * @author 雷楚桥
     * @date 2018-09-09 11:22
     */
    public FpSum createSum(Integer householdSum,
                           Integer poorHouseholdSum,
                           Integer poorSum,
                           Integer helperSum) {
        FpSum sum = new FpSum();
        sum.setHouseholdSum(householdSum);
        sum.setPoorHouseholdSum(poorHouseholdSum);
        sum.setPoorSum(poorSum);
        sum.setHelperSum(helperSum);

        return sum;
    }

    /**
     * @param townSum FpTownSum 当前乡镇统计
     * @return FpThanMonth
     * @deprecation 创建一个乡镇上月比较实例
     * @author 雷楚桥
     * @date 2018-09-09 16:23
     */
    public FpThanMonth createThanMonth(FpTownSum townSum) {
        Random random = new Random();

        FpThanMonth thanMonth = new FpThanMonth();
        thanMonth.setTownId(townSum.getTownId());                           //乡镇id

        thanMonth.setBangfCount(townSum.getHelperCount());                  //帮扶人数
        thanMonth.setBangfCountThan(300 + random.nextInt(400));      //与上月比较，帮扶人数

        thanMonth.setFivebCount(townSum.getWbrks());                        //五保人口数
        thanMonth.setFivebCountThan(500 + random.nextInt(600));      //与上月比较，五保人口数

        thanMonth.setLowbCount(townSum.getDbPopulation());                  //低保人口数
        thanMonth.setLowbCountThan(200 + random.nextInt(200));       //与上月比较,低保人口数

        thanMonth.setPoorVillage(townSum.getPoorVillage());                //贫困村数量
        thanMonth.setPoorVillageThan(random.nextInt(2));              //与上月比较,贫困村数量


        return thanMonth;
    }

}
